{extend name="public:public" /}
{block name="section"}
<section class="Hui-article-box">
    <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 订单管理 <span class="c-gray en">&gt;</span> 订单列表 <a
            class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
            href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a></nav>
    <div class="Hui-article">
        <article class="cl pd-20">
            <form action="" method="post">

                <div class="text-c">
                    <span class="select-box inline">
                        <select name="order_type" class="select">
                            <option value="0">全部分类</option>
                            <option value="1">微信支付</option>
                            <option value="2">余额支付</option>
                        </select>
                    </span>
                    <span class="select-box inline">
                        <select name="order_status" class="select">
                            <option value="0">全部状态</option>
                            <option value="1">待付款</option>
                            <option value="2">客户已付款,待发货</option>
                            <option value="3">配送中</option>
                            <option value="4">订单完成</option>
                            <option value="5">商家审核退款</option>
                            <option value="6">审核通过,退款中</option>
                            <option value="7">退款成功</option>
                            <option value="8">订单关闭</option>
                        </select>
                    </span>
                    <span class="select-box inline">
                        <select name="is_comment" class="select">
                            <option value="0">不检索是否评价</option>
                            <option value="1">已评价</option>
                            <option value="2">未评价</option>
                        </select>
                    </span>
                    日期范围：
                    <input type="text" onfocus="WdatePicker({maxDate:'#F{ $dp.$D(\'datemax\')||\'%y-%M-%d\'}'})" id="datemin" class="input-text Wdate" style="width:120px;" name="start_time">
                    <input type="text" onfocus="WdatePicker({minDate:'#F{ $dp.$D(\'datemin\')}',maxDate:'%y-%M-%d'})" id="datemax" class="input-text Wdate" style="width:120px;" name="end_time">
                    <input type="text" class="input-text" style="width:250px" placeholder="输入会员电话" id="" name="phone">
                    <button type="submit" class="btn btn-success radius" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜索订单</button>
                </div>
            </form>
            <div class="cl pd-5 bg-1 bk-gray mt-20"><span class="l"></span>
                <a href="{:url('admin/order/orderList')}" class="btn btn-primary radius" >全部订单</a>
                <a href="{:url('admin/order/checkPendingOrder',['status'=>2])}"  class="btn btn-warning radius"> 待发货订单</a>
                <span class="r">共有数据：<strong>{$data->total()}</strong> 条</span>
            </div>
            <div class="mt-20">
            <div class="mt-20">
                <table class="table table-border table-bordered table-hover table-bg table-sort">
                    <thead>
                    <tr class="text-c">
                        <td width="110">订单号</td>
                        <th width="80">类型</th>
                        <th width="70">状态</th>
                        <th width="120">用户名</th>
                        <th width="120">收件人姓名</th>
                        <th width="90">手机</th>
                        <th width="50">评论</th>
                        <th width="">地址</th>
                        <th width="80">金额</th>
                        <th width="130">创建时间</th>
                        <th width="100">快捷操作</th>
                        <th width="100">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {volist name='data' id='vo'}
                    <tr class="text-c">
                        <td>{$vo.sn}</td>
                        <td>
                            {switch name="$vo.type" }
                            {case value="1"}微信支付{/case}
                            {case value="2"}余额支付{/case}
                            {/switch}
                        </td>
                        <td class="td-status">
                            {switch name="$vo.status" }
                            {case value="1"}
                            <span class="label label-secondary radius">待付款</span>
                            {/case}
                            {case value="2"}
                            <span class="label label-warning radius">客户已付款,待发货</span>
                            {/case}
                            {case value="3"}
                            <span class="label label-secondary radius">配送中</span>
                            {/case}
                            {case value="4"}
                            <span class="label label-success radius">订单完成</span>
                            {/case}
                            {case value="5"}
                            <span class="label label-warning radius">商家审核退款</span>
                            {/case}
                            {case value="6"}
                            <span class="label label-secondary radius">审核通过,退款中</span>
                            {/case}
                            {case value="7"}
                            <span class="label label-success radius">退款成功</span>
                            {/case}
                            {case value="8"}
                            <span class="label label-danger radius">订单关闭</span>
                            {/case}
                            {default /}
                            <span class="label label-danger radius">订单异常</span>
                            {/switch}
                        </td>
                        <td><u style="cursor:pointer" class="text-primary">{$vo.user.nickname}</u>
                        </td>
                        <td class="td_name">{$vo.name}</td>
                        <td class="td_phone">{$vo.phone}</td>
                        <td>
                            {eq name="vo.is_comment" value="1"}
                            未评价
                            {else/}
                            已评价
                            {/eq}
                        </td>
                        <td class="text-l">{$vo.address}</td>
                        <td>{$vo.true_price}</td>
                        <td>{$vo.create_time}</td>

                        <td class="td-manage">
                            {if condition="$vo.status==2"}
                                <a title="确认发货" href="javascript:;" onclick="jie_dan(this,'{$vo.id}',12)" class="ml-5"
                                style="text-decoration:none">
                                <i class="Hui-iconfont">&#xe627;</i></a>
                            {/if}

                            {if condition="$vo.type==1 and $vo.status==5"}
                            <a title="确认退款" href="javascript:;" onclick="jie_dan(this,'{$vo.id}',15)" class="ml-5"
                               style="text-decoration:none">
                                <i class="Hui-iconfont">&#xe66c;</i></a>
                            {/if}


                            <!--{if condition="$vo.type==2 and $vo.status==8"}-->
                            <!--<a title="确认接单" href="javascript:;" onclick="jie_dan(this,'{$vo.id}',23)" class="ml-5"-->
                               <!--style="text-decoration:none">-->
                                <!--<i class="Hui-iconfont">&#xe6e1;</i></a>-->
                            <!--{/if}-->
                            <!--{if condition="$vo.type==3 and $vo.status==10"}-->
                            <!--<a title="确认已领取" href="javascript:;" onclick="jie_dan(this,'{$vo.id}',34)" class="ml-5"-->
                               <!--style="text-decoration:none">-->
                                <!--<i class="Hui-iconfont">&#xe6a7;</i></a>-->
                            <!--{/if}-->
                            <!--{if condition="$vo.type==2 and $vo.status==3"}-->
                            <!--<a title="确认配送成功" href="javascript:;" onclick="jie_dan(this,'{$vo.id}',24)" class="ml-5"-->
                               <!--style="text-decoration:none">-->
                                <!--<i class="Hui-iconfont">&#xe6a7;</i></a>-->
                            <!--{/if}-->
                            <!--{if condition="$vo.type==2 and $vo.status==9"}-->
                            <!--<a title="确认退款" href="javascript:;" onclick="jie_dan(this,'{$vo.id}',40)" class="ml-5"-->
                               <!--style="text-decoration:none">-->
                                <!--<i class="Hui-iconfont">&#xe6a7;</i></a>-->
                            <!--{/if}-->
                            <!--{if condition="$vo.type==2 and $vo.status==9"}-->
                            <!--<a title="拒绝退款" href="javascript:;" onclick="jie_dan(this,'{$vo.id}',41)" class="ml-5"-->
                               <!--style="text-decoration:none">-->
                                <!--<i class="Hui-iconfont">&#xe6a6;</i></a>-->
                            <!--{/if}-->
                            <!--<a style="text-decoration:none"-->
                               <!--onClick="order_detail('订单详情','/admin/order/orderDetail/order_id/{$vo.id}','700','600')"-->
                               <!--href="javascript:;" title="查看详情">-->
                                <!--<i class="Hui-iconfont">&#xe627;</i></a>-->
                        </td>
                        <td></td>
                    </tr>
                    {/volist}
                    </tbody>
                </table>
                {$data->render()}
            </div>
        </article>
    </div>
</section>
<script type="text/javascript">


    $('#menu-order').children('dt').addClass('selected');
    $('#menu-order').children('dd').show();
    $('#menu-order').children('dd').find('a').eq(0).css({
        color:'#148cf1',
        backgroundColor:'#FFF'
    });

    $(function () {
        // $('.table-sort').dataTable({
        //     "aaSorting": [[1, "desc"]],//默认第几个排序
        //     "bStateSave": true,//状态保存
        //     "aoColumnDefs": [
        //         //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
        //         {"orderable": false, "aTargets": [0, 8, 9]}// 制定列不参与排序
        //     ]
        // });
        $('.table-sort tbody').on('click', 'tr', function () {
            if ($(this).hasClass('selected')) {
                $(this).removeClass('selected');
            }
            else {
                table.$('tr.selected').removeClass('selected');
                $(this).addClass('selected');
            }
        });
    });


    /*确认接单*/
    function jie_dan(obj, id, type) {
        var trnow = $(obj).parents('tr');
        var name = trnow.children('.td_name').html();
        var phone = trnow.children('.td_phone').html();
        var address = trnow.children('.text-l').html();
        console.log(name,phone,address);
        layer.confirm('确认发货吗？<br/>收&nbsp;件&nbsp;人&nbsp;:&nbsp;'+ name +'<br/>联系电话:&nbsp;'+phone+'<br/>收件地址:&nbsp;'+address, function (index) {
            $.ajax({
                type: 'POST',
                url: '/admin/order/changeStatus',
                data: {'order_id': id, 'type': type},
                dataType: 'json',
                success: function (data) {
                    if (data.status == 1) {
                        layer.msg(data.msg);
                    } else {
                        layer.msg(data.msg);
                    }
                    location.reload();
                },
            });
        });
    }
</script>
{/block}

